package com.splic.api.controller.product;

import com.splic.common.core.domain.ResponseObj;
import com.splic.common.exception.BusinessException;
import com.splic.common.utils.StringUtils;
import com.splic.product.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * ==========================
 * 开发：singe
 * 创建时间：2022-03-30 21:04
 * 版本: 1.0
 * 描述：TODO
 * ==========================
 */
@Controller
@Slf4j
@RequestMapping("/api/email")
public class EmailVerificationController {

    @Autowired
    private UserService userServiceImpl;

    private String prefix = "product/emailVer";

    /**
     * 注册发送邮箱验证码接口
     * @return
     */
    @GetMapping("/emailVerification")
    public String emailVerification(@RequestParam String random){
        try{
            if(StringUtils.isEmpty(random)){
            }
            userServiceImpl.verification(random);
            return prefix + "/verSuccess";
        }catch (BusinessException e){
            log.error("链接验证失败:{}",e.getMessage());
            if(e.getCode() == 1){
                return prefix + "/hasVer";
            }
        }catch (Exception e){
            log.error("链接验证失败:{}",e.getMessage());
        }
        return prefix + "/verFail";
    }

}
